package com.sltx.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${file-save-path}")
    private String fileSavePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /**
         * 配置资源映射
         * 意思是：如果访问的资源路径是以“/aaa/”开头的，
         * 就给我映射到本机的“D:/aaa/”这个文件夹内，去找你要的资源
         * 注意：D:/aaa/ 后面的 “/”一定要带上
         */
        registry.addResourceHandler(fileSavePath + "**").addResourceLocations("file:" + fileSavePath);

//        registry.addResourceHandler("/aaa/**").addResourceLocations("file:"+fileSavePath);
    }


}

